<?php

pc_base::load_app_class('admin','admin',0);
class mes extends admin {
	
	function __construct(){
		$this->db = pc_base::load_model('mes_model');
	}
	
	function init(){
	}
	
	function mes_list(){
		$mes = $this->db->listinfo('', 'mesid desc',$_GET['page'], '20');
		$pages = $this->db->pages;
		//print_r($mes);
		include $this->admin_tpl('list');
	}
	
	function delete(){
		//print_r($_POST['mesid']);
		foreach ($_POST['mesid'] as $val) {
			$this->db->delete(array('mesid' => $val));
		}
		showmessage("删除成功！", HTTP_REFERER);
	}
	
	function show_mes(){
		foreach ($_POST['mesid'] as $val) {
			$res = $this->db->get_one(array('mesid' => $val),'show_mes');
			if(0==$res['show_mes'])$this->db->update(array('show_mes'=>'1'),array('mesid' => $val));
			else if(1==$res['show_mes'])$this->db->update(array('show_mes'=>'0'),array('mesid' => $val));
			else showmessage("参数错误，前台显示失败！", HTTP_REFERER);
		}
		showmessage("前台显示成功！", HTTP_REFERER);
	}
	
	function mes_re(){
		$_GET['mesid'] = intval($_GET['mesid']);
		if(!$_GET['mesid']) showmessage('参数错误！');
		if(isset($_POST['dosubmit'])){
			$_POST['mes']['re_time'] = time();
			if($this->db->update($_POST['mes'], array('mesid' => $_GET['mesid']))) showmessage('操作成功！', HTTP_REFERER, '', 'edit');
			///print_r($_POST);
		}else{
			$where = array('mesid' => $_GET['mesid']);
			$mes_info = $this->db->get_one($where);
			include $this->admin_tpl('mes_re');	
		}

	}

}
?>